# 获取1-100的随机数字
import random
num = random.randint(1, 100)

# 通过一个布尔类型的变量，标记循环是否继续
flag = True
count = 0

while flag:
    guess_num = int(input("请输入你猜测的数字"))
    count += 1
    if guess_num == num:
        print("猜中了")
        flag = False
    else:
        if guess_num > num:
            print("你猜大了")
        else:
            print("你猜小了")

print(f"你总共猜测了{count}次")
